home *** CD-ROM | disk | FTP | other *** search
- library ListMenu;
- {$DEFINE HACK}
- uses
- ShareMem, ExptIntf, ToolIntf, Menus, Forms, Dialogs, Classes,
- SysUtils;
-
- { EXPERT TYPE DEFINITION }
-
- Type
- TBListMenuExpert = class(TIExpert)
- public
- constructor Create; virtual;
-
- function GetStyle: TExpertStyle; override;
- function GetIDString: String; override;
- function GetName: String; override;
- function GetAuthor: String; override;
- end {TBListMenuExpert};
-
- { EXPERT SUPPORT FUNCTION }
-
- procedure HandleException;
- begin
- if Assigned(ToolServices) then
- ToolServices.RaiseException(ReleaseException)
- { Aplication.Handle := ToolServices.GetParentHandle; }
- end {HandleException};
-
- { EXPERT IMPLEMENTATION }
-
- constructor TBListMenuExpert.Create;
- var Main: TIMainMenuIntf;
- MenuItems: TIMenuItemIntf;
- ToolsTools: TIMenuItemIntf;
- Tools: TIMenuItemIntf;
- var i,j: Integer;
- f: System.Text;
- begin
- inherited Create;
- if ToolServices <> nil then
- try
- Main := ToolServices.GetMainMenu;
- if Main <> nil then { we've got the main menu }
- try
- MenuItems := Main.GetMenuItems;
- if MenuItems <> nil then
- try
- System.Assign(f,'C:\MENU');
- System.Rewrite(f);
- writeln(f,MenuItems.GetName,' -',MenuItems.GetItemCount);
- for i:=0 to Pred(MenuItems.GetItemCount) do
- begin
- Tools := MenuItems.GetItem(i);
- if Tools <> nil then { we've got a sub-menu }
- try
- writeln(f,' ',Tools.GetName);
- {$IFDEF HACK}
- Tools.SetCaption(Format('menu%d',[i]));
- {$ENDIF}
- for j:=0 to Pred(Tools.GetItemCount) do
- begin
- ToolsTools := Tools.GetItem(j);
- if ToolsTools <> nil then { sub-sub-menu }
- try
- writeln(f,' ',ToolsTools.GetName);
- {$IFDEF HACK}
- ToolsTools.SetCaption(Format('submenu%d.%d',[i,j]));
- {$ENDIF}
- finally
- {$IFNDEF HACK}
- ToolsTools.DestroyMenuItem
- {$ENDIF}
- end
- end
- finally
- {$IFNDEF HACK}
- Tools.DestroyMenuItem
- {$ENDIF}
- end
- end
- finally
- System.Close(f);
- MenuItems.DestroyMenuItem
- end
- finally
- Main.Free
- end
- except
- HandleException
- end
- end {Create};
-
- function TBListMenuExpert.GetStyle: TExpertStyle;
- begin
- try
- Result := esAddIn
- except
- HandleException
- end
- end {GetStyle};
-
- function TBListMenuExpert.GetIDString: String;
- begin
- try
- Result := 'DrBob.ListMenu.Expert'
- except
- HandleException
- end
- end {GetIDString};
-
- function TBListMenuExpert.GetName: String;
- begin
- try
- Result := 'DrBob.ListMenu.Expert'
- except
- HandleException
- end
- end {GetName};
-
- function TBListMenuExpert.GetAuthor: String;
- begin
- try
- Result := 'Bob.Swart'
- except
- HandleException
- end
- end {GetAuthor};
-
-
- { DLL EXPERT INTERFACE }
-
- procedure DoneExpert;
- begin
- { ShowMessage(ParamStr(0)+' unloaded!') }
- end {DoneExpert};
-
- function InitExpert(ToolServices: TIToolServices;
- RegisterProc: TExpertRegisterProc;
- var Terminate: TExpertTerminateProc): Boolean; stdcall;
- begin
- try
- Result := True;
- ExptIntf.ToolServices := ToolServices; { Save! }
- if ToolServices <> nil then
- Application.Handle := ToolServices.GetParentHandle;
- Terminate := DoneExpert;
- Result := RegisterProc(TBListMenuExpert.Create);
- except
- HandleException
- end
- end {InitExpert};
-
- exports
- InitExpert name ExpertEntryPoint;
-
- begin
- { ShowMessage(ParamStr(0)+' loaded!') }
- end.
-